package com.oowoo.rabbitmqserver2000.service;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author ZhangBin
 * @Date 2021/5/7 15:27
 * @Description: 发送mQ消息
 *
 **/
@Service
public class SendService {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    public void send(){

        //直连交换机 测试
        rabbitTemplate.convertAndSend("DIRECT_EXCHANGE","gupao.best","直连 消息");

        //主题交换机 测试
        rabbitTemplate.convertAndSend("TOPIC_EXCHANGE","shanghai.gupao.teacher","主题 消息-上海");
        rabbitTemplate.convertAndSend("TOPIC_EXCHANGE","长沙.gupao.teacher","主题 消息-长沙");

        //广播交换机  测试
        rabbitTemplate.convertAndSend("FANOUT_EXCHANGE","","广播 消息");

    }

}
